package com.nbpt;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import org.apache.http.conn.scheme.HostNameResolver;

import java.util.jar.Attributes;

public class MainActivity extends Activity {
    private EditText NameTB;
    private EditText PasswordTB;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        NameTB = findViewById(R.id.NameTB);
        PasswordTB = findViewById(R.id.PasswordTB);
        NameTB.setHint("请输入用户名");
        PasswordTB.setHint("请输入密码");
    }

    public void loginClick(View view)
    {
        String UserName = NameTB.getText().toString();
        String Password = PasswordTB.getText().toString();
        Log.d("Main","用户名为："+UserName);
        Log.d("Main","密码为："+Password);
        if(UserName.equals(""))
        {
            NameTB.requestFocus();
            Toast.makeText(this,"用户名为空，请输入",Toast.LENGTH_SHORT).show();
        }
        else if(Password.equals(""))
        {
            PasswordTB.requestFocus();
            Toast.makeText(this,"密码为空，请输入",Toast.LENGTH_SHORT).show();
        }
        else if(UserName.equals("admin") && Password.equals("123456"))
        {
            Toast.makeText(this,"登录成功",Toast.LENGTH_SHORT).show();
        }
        else
        {
                Toast.makeText(this,"用户名或密码有错误",Toast.LENGTH_SHORT).show();
        }
        //Toast.makeText(this,"点击了登录按钮",Toast.LENGTH_LONG).show();
    }
}
